/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = frct_l7analyzer_set.c                              */
/*  NOTE      =                                                    */
/*  DATE      = 2016/03/03 by geyh                                 */
/*******************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>

#include "frcomm.h"
#include "frlog.h"
#include "frmem.h"
#include "frlist.h"
#include "frsutl.h"
#include "frhash2.h"
#include "conntrack.h"
#include "frame.h"
#include "frct_comm.h"
#include "frct_mng.h"
#include "apmtest_cunit.h"
#include "frct_hash.h"

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

void case1(void)
{
    Frlist_node *p_st_node = NULL;
    L7_analyzer *p_st_l7_analyzer = NULL;
    L7_module *p_st_l7_module = NULL;
    int i_ret = 0;
;

    p_st_l7_module = (L7_module *) frmalloc (sizeof(L7_module));
    memset (p_st_l7_module, 0x00, sizeof (L7_module));


    i_ret = frct_l7analyzer_set(p_st_l7_analyzer, p_st_l7_module);

    CU_ASSERT_EQUAL(i_ret, FR_FAIL);

    frfree (p_st_l7_module);
    return;
}


void case2(void)
{
    Frlist_node *p_st_node = NULL;
    L7_analyzer *p_st_l7_analyzer = NULL;
    L7_module *p_st_l7_module = NULL;
    int i_ret = 0;

    p_st_l7_analyzer = (L7_analyzer *)frmalloc(sizeof(L7_analyzer));
    memset(p_st_l7_analyzer, 0x00, sizeof(L7_analyzer));

    p_st_l7_module = (L7_module *) frmalloc (sizeof(L7_module));
    memset (p_st_l7_module, 0x00, sizeof (L7_module));


    i_ret = frct_l7analyzer_set(p_st_l7_analyzer, p_st_l7_module);

    CU_ASSERT_EQUAL(i_ret, FR_SUCC);

    frct_l7analyzer_free(p_st_l7_analyzer);
    frfree (p_st_l7_analyzer);
    frfree (p_st_l7_module);
    return;
}


int add_suite()
{
    CU_pSuite pSuite = NULL;

    pSuite = CU_add_suite("frct_l7analyzer_set 测试", __suite_init, __suite_cleanup);

    if (NULL == pSuite)
    {
        return 1;
    }


    //增加测试用例
    CU_add_test(pSuite, "case1", case1);
    CU_add_test(pSuite, "case2", case2);

    //  	CU_add_test(pSuite, "case3", case3);

    //  	CU_add_test(pSuite, "case4", case4);

    return 0;

}

int main(int argc, char **argv)
{
    fr_slab_init(52428800, "test");
    run_cunit(add_suite);
    fr_slab_destroy();

    return 0;
}
